package profiterole.tests;

import java.io.File;

import profiterole.api.OnUpdateStatusCallback;
import profiterole.api.Waffle;
import profiterole.mapreduce.MapReduceService;
import profiterole.mapreduce.Splitter;
import profiterole.samples.PrintPromptListener;

public class TestSuite {
	
	public static void testParameters() {
		
		String all = System.getProperty("user.dir") + "/MapJobs/";
		@SuppressWarnings("unused")
		Waffle<?> result = MapReduceService.mapReduce(Splitter.folderToFileList(new File(all)));
		System.out.println("Test 1");
		
		result = MapReduceService.mapReduce(Splitter.folderToFileList(new File(all)), null);
		System.out.println("Test 2");
		
		result = MapReduceService.mapReduce(Splitter.folderToFileList(null));
		System.out.println("Test 3");

		result = MapReduceService.mapReduce(null);
		System.out.println("Test 4");
		
	}

	public static void testFlow() {
		
		String all = System.getProperty("user.dir") + "/MapJobs/";
		// String one = System.getProperty("user.dir") +"/OneFile/";

		OnUpdateStatusCallback listener = new PrintPromptListener(); 
		System.out.println(MapReduceService.mapReduce(Splitter.folderToFileList(new File(all)), listener).getSortedUnModifiableList());
	}
	
	public static void testInvertedIndex() {
		
		throw new RuntimeException("Not implemented yet");
		
		/*
		String all = System.getProperty("user.dir") + "/MapJobs/";
		// String one = System.getProperty("user.dir") +"/OneFile/";

		StatusListener listener = new PrintPromptListener();
		WordsToOccurencesMap result = MapReduceService.mapReduce(MapReduceService.folderToFileList(all), listener);
		System.out.println(result.doInvertedIndex("exceptional"));

		ArrayList<String> keys = new ArrayList<String>();
		keys.add("exceptional");
		keys.add("Jack-in-office");

		System.out.println(result.doInvertedIndex(keys));*/		
	}
	
public static void testBig() {
		
		String all = System.getProperty("user.dir") + "/MapJobs/";
		// String one = System.getProperty("user.dir") +"/OneFile/";

		OnUpdateStatusCallback listener = new PrintPromptListener(); 
		System.out.println(MapReduceService.mapReduce(
				Splitter.folderToFileList(new File("C://Projects//BigData//Sample//Process")), listener).getSortedUnModifiableList());
	}
	
	public static void main(String[] args) {
		testParameters();
		testFlow();
		//testBig();
		//testInvertedIndex();
	}
}